import pygame


def main():
    pygame.init()
    screen = pygame.display.set_mode((800, 600), 0, 32)

    sprite = pygame.image.load("cursor.png")

    x = 0

    clock = pygame.time.Clock()
    speed = 250  # 每秒移动的像素数

    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                exit()

        # 填充背景颜色
        screen.fill((255, 255, 255))

        # 图片移动
        screen.blit(sprite, (x, 100))

        timepassed = clock.tick()
        timepassed_seconds = timepassed / 1000
        distance_moved = timepassed_seconds * speed

        x += distance_moved

        # 大于窗口，则初始为0
        if x > 800:
            x = 0

        pygame.display.update()


main()
